﻿using System;
using System.Web.UI.WebControls;
using Ue.Framework.Web.WebControls;
using Ue.Infrastructure.DomainBase;
using Ue.Infrastructure.RepositoryFramework;
using Ue.Infrastructure.Web.UI;
using Ue.Qcdz.Domain;
using Ue.Qcdz.Domain.Adver;
namespace Ue.Qcdz.UI.Controls.Adver
{
    public class Advertisement : SkinnedGridView
    {
   

        private TextBox tbxWebSiteName;
        private TextBox tbxPageName;
        private TextBox tbxDivId;
        public string WebSiteName { get; set; }
        public string PageName { get; set; }
        public string DivId { get; set; }
        private string skinFileName = "~/Admin/Themes/Skins/Adver/Advertisements.ascx";
        private IAdvertisementRepository repository;
        public  Advertisement()
        {
            this.WebSiteName = SiteContext.GetSiteContext().WebSiteName;
            this.PageName = SiteContext.GetSiteContext().PageName;
            this.DivId = SiteContext.GetSiteContext().DivId;
            this.repository = RepositoryFactory.GetRepository<IAdvertisementRepository, Domain.Adver.Advertisement>();
        }
        #region Overrides of SkinnedControl
        protected override string GetSkinFileName()
        {
            return skinFileName;
        }
       
        #endregion
        protected override void InitializeSkin(System.Web.UI.Control skin)
        {
            base.InitializeSkin(skin);
            tbxWebSiteName = skin.FindControl<TextBox>("tbxWebSiteName");
            tbxPageName = skin.FindControl<TextBox>("tbxPageName");
            tbxDivId = skin.FindControl<TextBox>("tbxDivId");

        }

       
        #region Overrides of SkinnedGridView

        protected override void GridViewDataBind(object sender, EventArgs args)
        {

            IDataResult<Ue.Qcdz.Domain.Adver.Advertisement> dataResult = this.repository.FindBy(this);

            Repeater repeater = sender as Repeater;
            repeater.DataSource = dataResult.DataObjects;
            repeater.DataBind();
            this.RecordCount = dataResult.RecordCount;
        }

        #endregion
    }
}
